<?php

/**
 * 前台 活动图库 模块 Controller
 * ============================================================================
 * TBlog TBlog博客系统　BY Tmac PHP MVC framework
 * $Author: zwt007 $  <zwttmac@qq.com>
 * $Id: anli.php 39 2011-07-11 17:12:35Z zwt007 $
 * http://www.t-mac.org；
 */
class imageAction extends Action
{

    private $tmp_model;
    private $news_model;
    private $show_model;
    private $article_model;
    private $index_model;

    public function _init()
    {
        $this->assign('action', $_GET['TMAC_ACTION']);
        $this->tmp_model = Tmac::model('image');
        $this->news_model = Tmac::model('news');
        $this->show_model = Tmac::model('show');
        $this->article_model = Tmac::model('article', 'admin');
        $this->index_model = Tmac::model('index');

        $this->M('index')->getCommon();
    }

    public function index()
    {
        $name = 'images';
        $catinfo = $this->show_model->getCategoryInfo($name);
        $cid = $catinfo['cat_id'];
        
        //取文章信息
        $list = $this->tmp_model->getImageList('', $cid);

        $this->assign('cid', $cid);
        $this->assign('catinfo', $catinfo);
        $this->assign('list', $list);
        $this->V('image_list');
    }

    public function piclist()
    {        
        $name = empty($name) ? 'images' : $name;
        $catinfo = $this->show_model->getCategoryInfo($name);
        $cid = $catinfo['cat_id'];
        
        $id = intval($this->getParam('aid'));
        if (empty($id)) {
            $this->redirect('请选择图库！');
        }
        
        //取文章内的图片数组和文章详情字段
        $info = $this->tmp_model->getImageInfo($id);
        $img = $this->tmp_model->getCfgBody('img', $info['imgurls']);
        $imgurl_array = $img[2];
        $imgtitle_array = $img[1];
        
        $this->assign('catinfo', $catinfo);
        $this->assign('imgurl_array', $imgurl_array);
        $this->assign('imgtitle_array', $imgtitle_array);
        $this->assign('name', $name);
        $this->assign('info', $info);
        $this->V('image');
    }

    public function info()
    {
        $name = empty($name) ? 'images' : $name;
        $catinfo = $this->show_model->getCategoryInfo($name);
        $cid = $catinfo['cat_id'];

        $id = intval($this->getParam('aid'));
        if (empty($id)) {
            $this->redirect('请选择图库！');
        }
        $k = intval($this->getParam('k'));
        
        //取文章内的图片数组和文章详情字段
        $info = $this->tmp_model->getImageInfo($id);
        $img = $this->tmp_model->getCfgBody('img', $info['imgurls']);
        $imgurl_array = $img[2];
        $imgtitle_array = $img[1];

        $this->assign('catinfo', $catinfo);
        $this->assign('imgurl_array', $imgurl_array);
        $this->assign('imgtitle_array', $imgtitle_array);
        $this->assign('name', $name);
        $this->assign('info', $info);
        $this->assign('k', $k);
        $this->V('imageinfo');
    }

}